package org.chen.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.websocket.server.PathParam;
import org.apache.ibatis.annotations.Param;
import org.chen.common.SignUp;
import org.chen.common.UserWithChat;
import org.chen.dto.FindPasswordDto;
import org.chen.dto.LoginDto;
import org.chen.dto.RegisterDto;
import org.chen.dto.UpdatePasswordDto;
import org.chen.result.CommonResponse;
import org.chen.result.FindPasswordResponse;
import org.chen.result.RegisterResponse;
import org.chen.result.ResultBody;
import org.chen.service.UserWithChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/blink")
public class UserWithChatController {

    @Autowired
    private UserWithChatService userWithChatService;

    @PostMapping("/login")
    private ResultBody<Object> login(@RequestBody LoginDto loginDto){
        return ResultBody.success(userWithChatService.login(loginDto));
    }

    @PostMapping("/register")
    private ResultBody<RegisterResponse> register(@RequestBody RegisterDto registerDto){
        return ResultBody.success(userWithChatService.register(registerDto));
    }

    @GetMapping("/delete")
    private ResultBody<CommonResponse> delete(@RequestParam("objectId") String objectId){
        return ResultBody.success(userWithChatService.delete(objectId));
    }

    @PostMapping("/update")
    private ResultBody<CommonResponse> update(@RequestBody UserWithChat user){
        return ResultBody.success(userWithChatService.updateUser(user));
    }

    @PostMapping("/updatePassword")
    private ResultBody<CommonResponse> updatePassword(@RequestBody UpdatePasswordDto updatePasswordDto){
        return ResultBody.success(userWithChatService.updatePassword(updatePasswordDto));
    }

    @PostMapping("/changePassword")
    private ResultBody<CommonResponse> changePassword(@RequestBody UpdatePasswordDto updatePasswordDto){
        return ResultBody.success(userWithChatService.changePassword(updatePasswordDto));
    }

    @PostMapping("/findPassword")
    private ResultBody<FindPasswordResponse> findPassword(@RequestBody FindPasswordDto findPasswordDto){
        return ResultBody.success(userWithChatService.findPassword(findPasswordDto));
    }

    @PostMapping("/getUserWithChatByName")
    private ResultBody<CommonResponse> findPassword(@RequestBody UserWithChat userWithChat){
        return ResultBody.success(userWithChatService.getUserWithChatByName(userWithChat));
    }
}
